/**
  ******************************************************************************
  * @file           : axis.h
  * @brief          : Header for axis.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *	Created by Chen Lu in 20210527
  *
  ******************************************************************************
  */

#ifndef __AXIS_H
#define __AXIS_H

#include "motor.h"

#define AXIS_OK		1
#define AXIS_ERROR	0
#define MAX_ANGLE	642 / STEP_ANGLE		//need to be calibrated, here I use a approximate value.

typedef struct {
	uint8_t id;
	TiMotor * motor;
	uint16_t max_angle;		//max angle of each axis
	int encoder;			//it should be physical encoder, in this project, used to calculated pulses instead.
	uint8_t zero_flag;
}TiAxis;

TiAxis * axis_open(uint8_t id);
uint8_t axis_close(TiAxis * axis);
int axis_read(TiAxis * axis);
uint8_t axis_write (TiAxis * axis, uint8_t direction, uint16_t speed);
uint8_t axis_start(TiAxis * axis);
uint8_t axis_stop(TiAxis * axis);
uint8_t axis_returnzero(TiAxis * axis);

#endif /*__AXIS_H */


